                PicoMite - The story so far - Very Provisional Docs

* Loading MMBasic the first time
The Raspberry Pi Pico has its own bootloader in ROM. If you download matherp's
zip of the uf2 file that's all you need.
Connect your Pico to your PC while holding the BOOTSEL button down. It should
be recognised as a new drive (like a USB stick).
Open the drive and drag matherp's uf2 file (not the zip) into it.
You see a bargraph while it copies, then the new drive disappears and the Pico
reboots. It's now running MMBasic.
You'll need to connect to it using a termiinal program. Tera Term is
recommended for Windows.
Note: Don't bother looking for the uf2 file on the Pico or attempting to save
anything else to it. The bootloader is only a dummy drive, not a real one.
Everything else apart from a uf2 file is simply ignored.

This document refers to alpha releases of the software by release number,
Things change continually, so this is more of a time line than a manual.

From a14 the BOOTSEL button is rarely needed as UPDATE FIRMWARE can be used.
* Use
* OPTION RESET
* FLASH ERASE ALL
* VAR CLEAR
* to clean up before and after loading the alpha releases

Programs can be saved, loaded & erased from 10 flash memory areas:

FLASH ERASE n ' erases a flash program slot n=1 to 10
FLASH ERASE ALL ' erases all flash program slots
FLASH LIST 'Display list of flash area 1-10 contents
FLASH SAVE n ' Saves the current program to the flash slot specified
FLASH LOAD n ' Loads a program from the specified flash spot
FLASH RUN n ' Runs a program from the specified flash spot, clears all variables
FLASH CHAIN n ' Runs a program from the specified flash spot, leaves all
variables intact. Effectively your program can be much bigger than RAM allows.

OPTION AUTORUN OFF|ON|n where n is the flash program slot to be loaded and run
automatically on power-on or reset.

------------------------
a3
LIST COMMANDS
LIST OPTIONS
settick & watchdog working

------------------------
a4
PIN() can use either Picomite pin numbers or GPn references (see a19)

------------------------
a10
PIN(41) or PIN(GP25) can be put under user control instead of 'heartbeat' flasher
SETPIN 41, DOUT|HEARTBEAT
SETPIN GP25, DOUT|HEARTBEAT

------------------------
a12
PRINT PIN(TEMP) to read the temperature of the chip
Analogue input available on GP26, GP27 & GP28

------------------------
a13
HUMID pin, temp!, humid!, type
type=1 for DHT11 or omitted for DHT22
PORT()

------------------------
a14
OPTION POWER PFM|PWM
defaults to PFM mode
UPDATE FIRMWARE

------------------------
a15
SD card no longer configured by default.
OPTION SDCARD  SD_CLKpin, Option.SD_MOSIpin, SD_MISOpin, SD_CSpin
*** See a21 for changes to the above ***
for original connections use OPTION SDCARD 4,5,6,7
Available RAM reduced from 96k to 80k. 
About 50% increase in speed.

------------------------
a17
OPTION CPUSPEED cpuspeedinkhz
Defaults to 125000 with options cleared. 48000-250000 can be selected.

------------------------
a19
Up to 8 PWM channels (0-7) can be used. Each of these can have it's own
frequency.Each channel can have up to two outputs (A & B), which can have the
same or different duty cycle (0-100%). This gives a total of 16 PWM outputs.
The duty cycle can be a float value.

SETPIN pin, PWMnx.
PWM channel, frequency, [dutyA] [,dutyB]
PWM channel, OFF

e.g.

SETPIN 1,PWM0A    'Provisionally allocate pin 1 (GP0) to PWM0A
SETPIN 2,PWM0B    'Provisionally allocate pin 2 (GP1) tp PWM0B
PWM 0,1000,33,67  'Frequency is 1kHz for PWM0x, PWM0A is 33%, PWM0B is 67%
                  'The pins are now locked to PWM usage until PWM 0,OFF
PWM 0,OFF         'PWM0A and PWM0B are both off and the pins are released

The setpin can be changed until the PWM command is issued. At that point the
pin becomes locked to PWM until PWM n,OFF is issued
There are 8 separate PWM frequencies available (0 - 7) and up to 16 outputs
with individually controlled duty cycle. You can output on either PWMnA or
PWMnB or both for each channel - no restriction
Minimum frequency is given by the equation
65535 < (OPTION CPUSPEED * 1000)/256
This gives a minimum frequuency of 7.5Hz with a clock speed of 125MHz
Maximum speed is OPTION CPUSPEED/4
Of course at very fast speeds the duty cycles will be increasingly limited

Valid channels for PWM and other special functions are given in the attached
table and the codes for SETPIN are as in the table.
Pin Ref   Possible modes
1   GP0   DIGITAL_IN | DIGITAL_OUT | UART0TX | SPI0RX | I2C0SDA | PWM0A
2   GP1   DIGITAL_IN | DIGITAL_OUT | UART0RX | I2C0SCL | PWM0B
3   GND                                                        
4   GP2   DIGITAL_IN | DIGITAL_OUT | SPI0SCK | I2C1SDA | PWM1A
5   GP3   DIGITAL_IN | DIGITAL_OUT | SPI0TX | I2C1SCL | PWM1B
6   GP4   DIGITAL_IN | DIGITAL_OUT | UART1TX | SPI0RX | I2C0SDA | PWM2A
7   GP5   DIGITAL_IN | DIGITAL_OUT | UART1RX | I2C0SCL | PWM2B
8   GND
9   GP6   DIGITAL_IN | DIGITAL_OUT | SPI0SCK | I2C1SDA | PWM3A
10  GP7   DIGITAL_IN | DIGITAL_OUT | SPI0TX | I2C1SCL | EXT_PWM3B
11  GP8   DIGITAL_IN | DIGITAL_OUT | UART1TX | SPI1RX | I2C0SDA | PWM4A
12  GP9   DIGITAL_IN | DIGITAL_OUT | UART1RX | I2C0SCL | PWM4B
13        GND 
14  GP10  DIGITAL_IN | DIGITAL_OUT | SPI1SCK | I2C1SDA | PWM5A
15  GP11  DIGITAL_IN | DIGITAL_OUT | SPI1TX | I2C1SCL | PWM5B
16  GP12  DIGITAL_IN | DIGITAL_OUT | UART0TX | SPI1RX | I2C0SDA | PWM6A
17  GP13  DIGITAL_IN | DIGITAL_OUT | UART0RX | I2C0SCL | PWM6B
18        GND 
19  GP14  DIGITAL_IN | DIGITAL_OUT | SPI1SCK | I2C1SDA | PWM7A
20  GP15  DIGITAL_IN | DIGITAL_OUT | SPI1TX | I2C1SCL | PWM7B


21  GP16  DIGITAL_IN | DIGITAL_OUT | UART0TX | SPI0RX | I2C0SDA | PWM0A
22  GP17  DIGITAL_IN | DIGITAL_OUT | UART0RX | I2C0SCL | PWM0B
23        GND 
24  GP18  DIGITAL_IN | DIGITAL_OUT | SPI0SCK | I2C1SDA | PWM1A
25  GP19  DIGITAL_IN | DIGITAL_OUT | SPI0TX | I2C1SCL | PWM1B
26  GP20  DIGITAL_IN | DIGITAL_OUT | I2C0SDA | PWM2A
27  GP21  DIGITAL_IN | DIGITAL_OUT | I2C0SCL | PWM2B
28        GND  
29  GP22  DIGITAL_IN | DIGITAL_OUT | PWM3A
30        RUN   
31  GP26  DIGITAL_IN | DIGITAL_OUT | ANALOG_IN | I2C1SDA | PWM5A
32  GP27  DIGITAL_IN | DIGITAL_OUT | ANALOG_IN | I2C1SCL | PWM5B
33        AGND 
34  GP28  DIGITAL_IN | DIGITAL_OUT | ANALOG_IN | PWM6A
35        VREF
36        3V3 OUT
37        3V3 ENABLE
38        GND
39        VSYS
40        VBUS

41  GP25  DIGITAL_OUT | PWM4B    Onboard LED so not wired out to a pin

------------------------
a20
I2C (channel 0) and I2C1 (channel 1) added.

SETPIN pin, I2C0SDA
SETPIN pin, I2C0SCL
I2C OPEN speed,timeout
I2C WRITE addr, option, sendlen, senddata [,senddata ...]
I2C READ addr, option, rcvlen, revbuf
I2C CLOSE

SETPIN pin, I2C1SDA
SETPIN pin, I2C1SCL
I2C1 OPEN speed,timeout
I2C1 WRITE addr, option, sendlen, senddata [,senddata ...]
I2C1 READ addr, option, rcvlen, revbuf
I2C1 CLOSE

------------------------
a21
SPI added
SPI[1] OPEN freq, mode [,bits]
Use SPI1 command and function for SPI1aaa pins and SPI for spi0aaa pins
bits per transfer can be between 4 and 16

SETPIN 19,SPI1SCK
SETPIN 20,SPI1TR
SETPIN 16,SPI1RX
SPI1 OPEN 1000000,0
? SPI1(123)

Change to SDcard options to prepare for LCD panels and touch
OPTION SYSTEM SPI CLKpin, MOSIpin, MISOpin

To define the pin that is used for the SDcard chip select
OPTION SDCARD CSpin

Coming...
OPTION LCDPANEL type, RSpin, RESETpin, LCDCSpin
OPTION TOUCH IRQpin, CSpin

------------------------
a23
NAME command changed to RENAME
COPY fname1$ TO fname2$ added
MATH FFT added
PAUSE command improved

------------------------
a24
UARTS added, with partial testing

SETPIN 11, UART1TX
SETPIN 12, UART1RX
OPEN "COM1:115200" AS #1

SETPIN 1, UART0TX
SETPIN 2, UART0RX
OPEN "COM0:115200" AS #2

------------------------ 